<?php

/**
 * Form element for gPlusBadge
 *
 * @version  1.0
 * @author Daniel Eliasson (joomla at stilero.com)
 * @copyright  (C) 2012-maj-09 Stilero Webdesign http://www.stilero.com
 * @category Custom Form field
 * @license    GPLv2
 *
 * Joomla! is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 *
 * This file is part of gplusbadge.
 *
 * gPlusBadge is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * gPlusBadge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gPlusBadge.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
if(version_compare(JVERSION, '1.6.0', '<')){
    /**
     * @since J1.5
     */
    class JElementPastecode extends JElement{
        private $config;
        
        public function fetchElement($name, $value, &$node, $control_name){
            $document = & JFactory::getDocument();
            $this->config = array(
                'jsAsset' => 'js/pastecode15.js',
            );
            $basePathToPlugin = JURI::root(true) . '/plugins/content/';
            $document->addScript( $basePathToPlugin . $this->config['jsAsset'] );
            $htmlCode = '<textarea  id="' . $control_name.$name . '" name="' . $control_name.'['.$name.']' . '" value="' . $value . '" rows="5" cols="30" ></textarea>';
            return $htmlCode;
        }
    }//End 1.5 class
}else{
    class JFormFieldPastecode extends JFormField {

        protected $type = 'pastecode';
        private $config;

        protected function getInput() {
            $document = & JFactory::getDocument();
            $this->config = array(
                'jsAsset' => 'js/pastecode.js',
            );
            $basePathToPlugin = JURI::root(true) . '/plugins/content/gplusbadge/';
            $document->addScript( $basePathToPlugin . $this->config['jsAsset'] );
            $htmlCode = '<textarea  id="' . $this->id . '" name="' . $this->name . '" type="textarea" value="' . $this->value . '" rows="5" cols="30" ></textarea>';
            return $htmlCode;
        }

    }
}
//End Class